package Test;

public class Main {
    public static void main(String[] args) {
        //比较字符串方法
        String s1 = new String("hello world");
        String s2 = new String("HELLO World");
        boolean b = s1.equals(s2);
        System.out.println(b);
        b = s1.equalsIgnoreCase(s2);
        System.out.println(b);

        System.out.println("-----------------");

        //截取字符串内容（包前不包后）
        String rs = s1.substring(0, 5);
        System.out.println(rs);

        //截取后整段
        rs = s1.substring(6);
        System.out.println(rs);

        System.out.println("-----------------");

        //替换字符
        String s3 = new String("这电影好垃圾啊，垃圾电影，垃圾垃圾！");
        String rs3 = s3.replace("垃圾","**");
        System.out.println(rs3);

        //判断是否包含某个字符
        String s4 = new String("clannad是最好看的动漫");
        System.out.println(s4.contains("clannad"));

        //判断有没有以某个字符开头
        System.out.println(s4.startsWith("clannad"));

        System.out.println("-----------------");

        //以某一字符分割字符串
        String s5 = new String("《clannad》,《air》,《kanon》,《one》");
        String[] names = s5.split(",");
        for (int i = 0; i < names.length; i++) {
            System.out.print(names[i]);
        }
        System.out.println();
    }
}
